package com.iot.tob.platform.controller;


import com.iot.tob.platform.entity.DeviceApp;
import com.iot.tob.platform.service.IDeviceAppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Alex Wu
 * @since 2025-03-24
 */
@RestController
@RequestMapping("/device-app")
public class DeviceAppController {
    @Autowired
    private IDeviceAppService deviceAppService;

    @GetMapping
    public List<DeviceApp> getAllDeviceApps() {
        return deviceAppService.list();
    }

    @GetMapping("/{id}")
    public DeviceApp getDeviceAppById(@PathVariable Long id) {
        return deviceAppService.getById(id);
    }

    @PostMapping
    public Boolean createDeviceApp(@RequestBody DeviceApp deviceApp) {
        return deviceAppService.save(deviceApp);
    }

    @PutMapping("/{id}")
    public Boolean updateDeviceApp(@PathVariable Long id, @RequestBody DeviceApp deviceApp) {
        return deviceAppService.updateById(deviceApp);
    }

    @DeleteMapping("/{id}")
    public void deleteDeviceApp(@PathVariable Long id) {
        deviceAppService.removeById(id);
    }
}
